package com.topisv.tms.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import com.topisv.tms.entity.ShippedBoxOrdeno;

public interface ShippedBoxOrdenoDao extends PagingAndSortingRepository<ShippedBoxOrdeno, Long>, JpaSpecificationExecutor<ShippedBoxOrdeno>{
	
	
	@Modifying
	@Query("delete from ShippedBoxOrdeno sb where sb.batchCode=?1")
	void delete(String batchCode);

	List<ShippedBoxOrdeno> findByBoxCode(String boxCode);
	
	List<ShippedBoxOrdeno> findByStatus(String status);
	
	List<ShippedBoxOrdeno> findByBatchCodeAndStatus(String batchCode,String status);
	
	ShippedBoxOrdeno findByBoxCodeAndOrdeno(String boxCode,String ordeno);
	
	ShippedBoxOrdeno findByOrdeno(String ordeno);
	
	ShippedBoxOrdeno findByWaybillNo(String waybillNo);
	
	ShippedBoxOrdeno findByBoxCodeAndWaybillNo(String boxCode,String waybillNo);
	@Query("select s from  ShippedBoxOrdeno s where s.batchCode=?1 order by s.status desc")
	List<ShippedBoxOrdeno> findByBatchCode(String batchCode);
	
	List<ShippedBoxOrdeno> findByBatchCodeAndBoxCode(String batchCode,String boxCode);
	
	
}
